thin.imports('/public/configure/conf.minfo.js');
thin.imports('/public/home/resource/compress.js');
thin.imports('/public/plug/LoadEffect/LoadEffect.js');

thin.use(function() {
	// 頁面加載完畢
	thin.effect();
	
	layer.load(0, {
		shade: [0.08, '#000']
	});
	// 获取名片
	factory.request('_m_card');
	

	// 绑定压缩上传图片按钮
	$(document).on('change', '[layout-mark=uploadFile]', thin.uploadImage);
});

var __getdata_mcardcomplete = {};

// 获取名片回调
function __complete_mcards(res) {
	layer.closeAll('loading');
	if (res.status == 200) {
		if (res.data.card && res.data.card != '') {
			document.getElementById('bind-card').src = res.data.card;
		}
	}
}

// 上传名片回调
var __ucard = {
	'imgelem': function(obj) {
		layer.load(0, {
			shade: [0.08, '#000']
		});
		return document.getElementById('bind-card');
	},
	'process': function(base64) {

	},
	'complete': function(res) {
		if(res.status == 201) {
			$('#ipt-pc-card').val(res.data.uri);
			// 完善名片
			__getdata_mcardcomplete['uri'] = res.data.uri;
			factory.request('_m_cardcomplete');
		} else {
			layer.msg(res.error, {
				icon: 2,
				time: 800
			});
		}
	}
}

// 完善名片回调
function __complete_mcardcomplete(res) {
	layer.closeAll('loading');
	if(res.status == 201) {
		layer.msg('修改成功', {
			icon: 1,
			time: 1200
		}, function() {});
	} else {
		layer.msg(res.error, {
			icon: 2,
			time: 800
		});
	}
}